package org.summerframework.component.security.spring.auth;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

public class AuthedToken extends AbstractAuthenticationToken {

	private final Object principal;
	private Object credentials;

	/**
	 *
	 */
	private static final long serialVersionUID = -6210978461632393980L;

	public AuthedToken(Object principal, Collection<? extends GrantedAuthority> authorities) {
		super(authorities);
		this.principal = principal;
		super.setAuthenticated(true);
	}

	public AuthedToken(Object principal, Object  credentials , Collection<? extends GrantedAuthority> authorities) {
		this(principal,authorities);
		this.credentials = credentials;
	}

	public void setCredentials(Object credentials) {
		this.credentials = credentials;
	}

	@Override
	public Object getCredentials() {
		return this.credentials;
	}

	@Override
	public Object getPrincipal() {
		return this.principal;
	}

}
